﻿using AutoMapper;
using Volo.Abp.AutoMapper;

namespace ParkManagement
{
    /// <summary>
    /// 停哪儿管理应用自动映射配置
    /// </summary>
    public class ParkManagementApplicationAutoMapperProfile : Profile
    {
        public ParkManagementApplicationAutoMapperProfile()
        {
            CreateMap<Correct, CorrectDto>();


            CreateMap<Lot, LotDto>()
                .ForMember(m => m.AllPark, m => m.MapFrom(f => f.AllPark.ToString()))
                .ForMember(m => m.Vacancy, m => m.MapFrom(f => f.Vacancy.ToString()))
                .ForMember(m => m.Rates, m => m.MapFrom(f => f.Rates.ToString()))
                .ForMember(m => m.PriceCaps, m => m.MapFrom(f => f.PriceCaps.ToString()))
                .ForMember(m => m.Distance, m => m.MapFrom(f => f.Distance.ToString()))
                .ForMember(m => m.Open, m => m.MapFrom(f => f.Open.ToString()));
            CreateMap<Record, RecordDto>()
                .ForMember(m => m.EntryTime, m => m.MapFrom(f => f.EntryTime.ToString("yyyy-MM-dd HH:mm:ss")))
                .ForMember(m => m.OutTime, m => m.MapFrom(f => f.OutTime.HasValue ? f.OutTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : null))
                .ForMember(m => m.Monetary, m => m.MapFrom(f => f.Monetary.ToString()))
                .ForMember(m => m.ParkName, m => m.MapFrom(f => f.Lot.ParkName))
                .ForMember(m => m.Address, m => m.MapFrom(f => f.Lot.Address));
            

            CreateMap<Car, CarDto>()
                .ForMember(m => m.Type, m => m.MapFrom(f => f.Type.ToString()))
                .Ignore(m => m.UserName);
            CreateMap<Consumption, ConsumptionDto>()
                .ForMember(m => m.TravelDate, m => m.MapFrom(f => f.TravelDate.ToString("yyyy-MM-dd")))
                .ForMember(m => m.PlateNo, m => m.MapFrom(f => f.Car.PlateNo))
                .Ignore(m => m.UserName);
            CreateMap<Move, MoveDto>();
        }
    }
}